#!/usr/bin/env python
# encoding: utf-8
# @author: liusir
# @file: demo_06.py
# @time: 2022/11/13 2:17 PM
import re
var_dict = {"token_value":"88uu"}
str_1 = '{"access_token":"${token_value}"}'
# {"access_token":"88uu"}
value = re.findall( '\\${\w+}',str_1 )
print( value )
# str_1 = str_1.replace(value[0],"88uu")
# str_1 = str_1.replace(value[0],var_dict["token_value"])
str_1 = str_1.replace(value[0],var_dict[ value[0][2:-1] ])
print( str_1 )

var_dict_02 = {"n":"xiaobai","a":18}
str_2 = '{"name":${n},"age":${a}}'
values = re.findall( '\\${\w+}',str_2 )
for value in values:
    str_2 = str_2.replace(value, str( var_dict_02[value[2:-1]] ) )
    print( str_2 )


